<template>
	<view style="height: 100%">
	<view :class="'main' + (skin.IS_SUB ? 'sub-margin-bottom': '')">
		<view class="upside upside-shadow" @tap="url" :data-url="user ? '../edit':'../regdit'">
			<image mode="aspectFill" lazy-load class="upImg loading" src="/static/image/my.jpg" />
			<view class="user-bar">
				<view class="detail">
					<view class="name text-cut">{{ user ? user.USER_NAME : '欢迎回来~~~' }}</view>
					<view class="desc">
					    <view v-if="user && user.USER_STATUS == 9" class="tag small radius bg-purple light">已禁用</view>
					    <view v-else-if="user && user.USER_STATUS == 0" class="tag small radius bg-orange light">已注册，待审核</view>
					    <view v-else-if="user && user.USER_STATUS == 8" class="tag small radius bg-red light">审核未通过，请修改资料</view>
					    <view v-else class="text-cut">{{ user ? '欢迎回来~~~' : '马上注册，使用更多功能' }}</view>
					</view>
				</view>
				<view class="avatar">
				    <image mode="aspectFit" src="/static/image/table_my_cur.png" />
				</view>
			</view>
		</view>
		
		<view class="down padding-project">
			<view class="comm-list menu card-project shadow-project">
				<view v-if="user && user.USER_STATUS != 9" class="item arrow" @tap="url" data-url="../edit/my_edit">
				    <view class="content">
				        <text class="icon-edit my-icon-project text-green"></text>
				        <text class="text-black">修改我的个人资料</text>
				    </view>
				</view>
				
				<view class="item arrow" @tap="url" data-url="../../health/list/health_list?cateId=5">
				    <view class="content">
				        <text class="icon-calendar my-icon-project text-project"></text>
				        <text class="text-black">我的健康打卡</text>
				    </view>
				</view>
			</view>
			
			<view class="comm-list menu card-project shadow-project">
			    <view class="item arrow" @tap="url" data-url="../../health/list/health_list?cateId=1">
			        <view class="content">
			            <text class="icon-remind my-icon-project text-project"></text>
			            <text class="text-black">我的疫情排查</text>
			        </view>
			    </view>
			    <view class="item arrow" @tap="url" data-url="../../health/list/health_list?cateId=2">
			        <view class="content">
			            <text class="icon-activity my-icon-project text-project"></text>
			            <text class="text-black">我的出行报备</text>
			        </view>
			    </view>
			    <view class="item arrow" @tap="url" data-url="../../health/list/health_list?cateId=3">
			        <view class="content">
			            <text class="icon-write my-icon-project text-project"></text>
			            <text class="text-black">我的核酸报名</text>
			        </view>
			    </view>
			    <view class="item arrow" @tap="url" data-url="../../health/list/health_list?cateId=4">
			        <view class="content">
			            <text class="icon-squarecheck my-icon-project text-project"></text>
			            <text class="text-black">我的隔离统计</text>
			        </view>
			    </view>
			</view>
			
			<view class="comm-list menu card-project shadow-project">
			    <view v-if="skin.IS_SUB" class="item arrow" @tap="bindSetTap">
			        <view class="content">
			            <text class="icon-settings my-icon-project text-grey"></text>
			            <text class="text-red text-bold">
			                系统后台管理
			                <text class="text-grey text-normal">（点击试用）</text>
			            </text>
			        </view>
			    </view>
			
			    <view class="item arrow" @tap="url" data-url="../../about/index/about_index?key=SETUP_CONTENT_ABOUT">
			        <view class="content">
			            <text class="icon-service my-icon-project text-purple"></text>
			            <text class="text-black">关于我们</text>
			        </view>
			    </view>
			
			    <view v-if="skin.IS_SUB" class="item arrow" @tap="url" data-url="/pages/home/about/home_about">
			        <view class="content">
			            <text class="icon-phone my-icon-project text-cyan"></text>
			            <text class="text-orange">联系作者了解更多详情</text>
			        </view>
			    </view>
			
			    <view v-if="!skin.IS_SUB" class="item arrow" @tap="bindSetTap">
			        <view class="content">
			            <text class="icon-settings my-icon-project text-grey"></text>
			            <text class="text-black">设置</text>
			        </view>
			    </view>
			</view>
		</view>
		
	</view>
	
	<view style="height: 100rpx"></view>
	
	<block v-if="skin.IS_SUB">
	    <!-- parse <template is="menuTpl" :data="curMenu:'my_index',returnHome:false"/> -->
	    <template name="menuTpl" v-if="false">
	        <view class="tab-bar">
	            <view v-if="false" class="tab-bar-home" @tap="url" data-type="relaunch" data-url="/pages/home/index/home_index">
	                <text class="tab-bar-home-text icon-homefill text-grey"></text>
	            </view>
	
	            <view class="tab-bar-border"></view>
	            <view class="tab-bar-item" @tap="url" data-type="relaunch" data-url="/projects/epidemic/pages/default/index/default_index">
	                <image class="tab-icon" :src="'/projects/epidemic/images/tabbar/home' + ('home_index' == 'home_index' ? '_cur' : '') + '.png'"></image>
	                <view :class="'tab-text ' + ('home_index' == 'home_index' ? 'menu-project' : '')">首页</view>
	            </view>
	
	            <view class="tab-bar-item" @tap="url" data-type="relaunch" data-url="/projects/epidemic/pages/news/index/news_index">
	                <image class="tab-icon" :src="'/projects/epidemic/images/tabbar/news' + ('home_index' == 'news_index' ? '_cur' : '') + '.png'"></image>
	                <view :class="'tab-text ' + ('home_index' == 'news_index' ? 'menu-project' : '')">公告通知</view>
	            </view>
	
	            <view class="tab-bar-item" @tap="url" data-type="relaunch" data-url="/projects/epidemic/pages/my/index/my_index">
	                <image class="tab-icon" :src="'/projects/epidemic/images/tabbar/my' + ('home_index' == 'my_index' ? '_cur' : '') + '.png'"></image>
	                <view :class="'tab-text ' + ('home_index' == 'my_index' ? 'menu-project' : '')">我的</view>
	            </view>
	        </view>
	    </template>
	</block>
	</view>
</template>

<script>
	const PassportBiz = require('../../helper/passport_biz.js');
	const cacheHelper = require('../../helper/cache_helper.js');
	const cloudHelper = require('../../helper/cloud_helper.js');
	const pageHelper = require('../../helper/page_helper.js');
	const setting = require('../../helper/setting.js');
	const AdminBiz = require('../../helper/admin_biz.js');
	const ProjectBiz = require('../../helper/project_biz.js');
	
	export default {
		data() {
			return {
				skin: {
				    IS_SUB: false
				},
				user: {
				    USER_NAME: '',
				    USER_STATUS: 0
				},
			}
		},
		
		onLoad: async function (options) {
		    if (PassportBiz.isLogin()) {
		        let user = {};
		        user.USER_NAME = PassportBiz.getUserName();
		        this.setData({
		            user
		        });
		    }
		    ProjectBiz.initPage(this);
		},
		
		onReady: function () {},
		
		onShow: async function () {
		    PassportBiz.loginSilenceMust(this);
		    this.loadUserFun();
		},
		
		onHide: function () {},
		
		onUnload: function () {},
		
		onPullDownRefresh: async function () {
		    await this.loadUserFun();
		    uni.stopPullDownRefresh();
		},
		
		onReachBottom: function () {},
		
		onShareAppMessage: function () {},
		
		methods: {
			loadUserFun: async function(e){
				let opts = {
				    title: 'bar'
				};
				let user = await cloudHelper.callCloudData('passport/my_detail', {}, opts);
				if (!user) {
				    this.setData({
				        user: null
				    });
				    return;
				}
				this.setData({
				    user
				});
			},
			url: function(e){
				let url = e.currentTarget.dataset.url;
				if(!url) return;
				uni.switchTab({
					url
				});
			},
			bindSetTap: function (e, skin) {
			    let itemList = ['清除缓存', '后台管理'];
			    uni.showActionSheet({
			        itemList,
			        success: async (res) => {
			            let idx = res.tapIndex;
			            if (idx == 0) {
			                cacheHelper.clear();
			                pageHelper.showNoneToast('清除缓存成功');
			            }
			            if (idx == 1) {
			                if (setting.IS_SUB) {
			                    AdminBiz.adminLogin(this, 'admin', '123456');
			                } else {
			                    uni.reLaunch({
			                        url: '../../admin/index/login/admin_login'
			                    });
			                }
			            }
			        },
			        fail: function (res) {}
			    });
			}
		}
	}
</script>

<style>
@import '../../static/style/skin.css'

.main {
    padding: 0;
}

.main .upside {
    background-color: #e9faff;
    height: 350rpx;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding-top: 100rpx;
}

.main .upside .upImg {
    height: inherit;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.main .upside .user-bar {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding-left: 40rpx;
    z-index: 9999;
}

.main .upside .user-bar .avatar {
    height: 120rpx;
    width: 120rpx;
    border: 0rpx;
    font-size: 80rpx;
    border-radius: 50%;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main .upside .user-bar .avatar image {
    height: 70rpx;
    width: 70rpx;
}

.main .upside .user-bar .detail {
    width: 500rpx;
    margin-left: 0rpx;
    margin-right: 40rpx;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    color: #fff;
    box-sizing: border-box;
}

.main .upside .user-bar .detail .name {
    width: 100%;
    font-size: 36rpx;
    font-weight: bold;
    color: #fff;
}

.main .upside .user-bar .detail .desc {
    width: 100%;
    font-size: 26rpx;
    margin-top: 15rpx;
    color: yellow;
}

.main .down {
    box-sizing: border-box;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20rpx 0rpx !important;
    margin-top: 20rpx;
}

.main .down .data {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 150rpx;
    padding: 0rpx 40rpx 0rpx 40rpx;
    width: 100%;
    background-color: #fff;
}

.main .down .data view {
    width: 150rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.main .down .data view .num {
    font-size: 32rpx;
    font-weight: bold;
}

.main .down .data view .txt {
    font-size: 24rpx;
    color: #aaa;
}

.main .comm-list .item.arrow::before,
.main .comm-list .item .content .item-icon {
    color: #0e9489;
}

.main .down .today {
    width: 100%;
    padding: 30rpx 30rpx 20rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #fff;
}

.main .down .today .title {
    width: 100%;
    text-align: left;
    font-size: 32rpx;
    font-weight: bold;
    line-height: 1.2;
    margin-bottom: 30rpx;
}

.main .down .today .list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
}

.main .down .today .list .item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 15rpx 0;
    border-bottom: 1rpx dashed #ccc;
}

.main .down .today .list .item:last-child {
    margin-bottom: 0rpx;
    border: 0;
}

.main .down .today .list .item .time {
    font-size: 28rpx;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 2;
    font-weight: bold;
}

.main .down .today .list .item .time .status {
    font-weight: normal;
    font-size: 27rpx;
}

.main .down .today .list .item .project {
    color: #666;
    font-size: 24rpx;
    width: 100%;
    text-align: left;
}

.main .site-footer {
    width: 100%;
    align-self: flex-end;
}

.main .upside-shadow {
    box-shadow: unset;
}

.main .upside-shadow:before,
.main .upside-shadow:after {
    position: absolute;
    content: '';
    top: 20rpx;
    bottom: 30rpx;
    left: 20rpx;
    width: 50%;
    box-shadow: 0 30rpx 20rpx rgba(0, 0, 0, 0.2);
    transform: rotate(-3deg);
    z-index: -1;
}

.main .upside-shadow:after {
    right: 20rpx;
    left: auto;
    transform: rotate(3deg);
}

.down .comm-list.menu.card-project {
    border-radius: 0rpx !important;
}

.shadow-project {
    box-shadow: unset;
}
@import '@/HbuliderX/bin';
</style>
